function z = dot(x,y)
if ~isa(y,'deriv1f')
  z.v = dot(x.v,y);
  z.d = y(:)' * squeeze(x.d);
elseif ~isa(x,'deriv1f')
  z.v = dot(x,y.v);
  z.d = x(:)' * squeeze(y.d);
else
  z.v = dot(x.v,y.v);
  z.d = x.v(:)'*squeeze(y.d) + y.v(:)'*squeeze(x.d);
end

z=class(z,'deriv1f');

